package test;

import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;

import org.xmappr.Attribute;
import org.xmappr.Element;
import org.xmappr.Elements;
import org.xmappr.RootElement;
import org.xmappr.Xmappr;

@RootElement(name="A")
public class A extends SuperA {

	@Attribute
	public String AStr;

	@Elements({
		@Element(name="B1", targetType=B1.class),
		@Element(name="B2", targetType=B2.class)
	})
	public List<SuperB> list = new ArrayList<SuperB>();

	@Element
	public C c;
	
	public static void main(String[] args) {
		A a = new A();
		a.superAStr = "super...";
		a.AStr = "...";

		B1 b1 = new B1();
		b1.id = 1;
		b1.b1 = "b1...";
		a.list.add(b1);

		B2 b2 = new B2();
		b2.id = 2;
		b2.b2 = "b2...";
		a.list.add(b2);

		C c=new C();
		c.id=3;
		c.lb=b1;
		c.rb=b2;
		a.c=c;
		
		Xmappr xm = new Xmappr(A.class);
		xm.toXML(a, new OutputStreamWriter(System.out));
	}
}
